/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ghanaroutes.entities;

import com.alerts.Alert;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author User
 */
@Entity
@Table(name = "routes")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Routes.findAll", query = "SELECT r FROM Routes r"),
    @NamedQuery(name = "Routes.findByRouteId", query = "SELECT r FROM Routes r WHERE r.routeId = :routeId"),
    @NamedQuery(name = "Routes.findByDescription", query = "SELECT r FROM Routes r WHERE r.description = :description"),
    @NamedQuery(name = "Routes.findByUserId", query = "SELECT r FROM Routes r WHERE r.userId = :userId"),
    @NamedQuery(name = "Routes.findByMode", query = "SELECT r FROM Routes r WHERE r.mode = :mode"),
    @NamedQuery(name = "Routes.findByStartLoc", query = "SELECT r FROM Routes r WHERE r.startLoc LIKE :startLoc"),
    @NamedQuery(name = "Routes.findByEndLoc", query = "SELECT r FROM Routes r WHERE r.endLoc LIKE :endLoc"),
    @NamedQuery(name = "Routes.findByDuration", query = "SELECT r FROM Routes r WHERE r.duration = :duration"),
    @NamedQuery(name = "Routes.findByDistance", query = "SELECT r FROM Routes r WHERE r.distance = :distance"),
    @NamedQuery(name = "Routes.findByStartEndLoc", query = "SELECT r FROM Routes r WHERE r.startLoc LIKE :startLoc and r.endLoc LIKE :endLoc"),
    @NamedQuery(name = "Routes.findByDateAdded", query = "SELECT r FROM Routes r WHERE r.dateAdded = :dateAdded")})
public class Routes implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "route_id")
    private Integer routeId;
    @Lob
    @Size(max = 65535)
    @Column(name = "pathLong")
    private String pathLong;
    @Lob
    @Size(max = 65535)
    @Column(name = "pathLat")
    private String pathLat;
    @Size(max = 200)
    @Column(name = "description")
    private String description;
    @Column(name = "user_id")
    private Integer userId;
    @Size(max = 20)
    @Column(name = "mode")
    private String mode;
    @Size(max = 50)
    @Column(name = "startLoc")
    private String startLoc;
    @Size(max = 50)
    @Column(name = "endLoc")
    private String endLoc;
    @Size(max = 15)
    @Column(name = "duration")
    private String duration;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "distance")
    private Float distance;
    @Column(name = "date_added")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateAdded;

    @OneToMany(mappedBy = "route", fetch = FetchType.LAZY)
    private List<Alert> alerts;

    public List<Alert> getAlerts() {
        return alerts;
    }

    public void setAlerts(List<Alert> alerts) {
        this.alerts = alerts;
    }
    
    
    
    public Routes() {
    }

    public Routes(Integer routeId) {
        this.routeId = routeId;
    }

    public Routes(Integer routeId, Date dateAdded) {
        this.routeId = routeId;
        this.dateAdded = dateAdded;
    }

    public Integer getRouteId() {
        return routeId;
    }

    public void setRouteId(Integer routeId) {
        this.routeId = routeId;
    }

    public String getPathLong() {
        return pathLong;
    }

    public void setPathLong(String pathLong) {
        this.pathLong = pathLong;
    }

    public String getPathLat() {
        return pathLat;
    }

    public void setPathLat(String pathLat) {
        this.pathLat = pathLat;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getMode() {
        return mode;
    }

    public void setMode(String mode) {
        this.mode = mode;
    }

    public String getStartLoc() {
        return startLoc;
    }

    public void setStartLoc(String startLoc) {
        this.startLoc = startLoc;
    }

    public String getEndLoc() {
        return endLoc;
    }

    public void setEndLoc(String endLoc) {
        this.endLoc = endLoc;
    }

    public String getDuration() {
        return duration;
    }

    public void setDuration(String duration) {
        this.duration = duration;
    }

    public Float getDistance() {
        return distance;
    }

    public void setDistance(Float distance) {
        this.distance = distance;
    }

    public Date getDateAdded() {
        return dateAdded;
    }

    public void setDateAdded(Date dateAdded) {
        this.dateAdded = dateAdded;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (routeId != null ? routeId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Routes)) {
            return false;
        }
        Routes other = (Routes) object;
        if ((this.routeId == null && other.routeId != null) || (this.routeId != null && !this.routeId.equals(other.routeId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ghanaroutes.entities.Routes[ routeId=" + routeId + " ]";
    }
    
}
